from django.db import models
from info.models import Student


# Create your models here.
class Activity(models.Model):
    name = models.CharField(verbose_name='活动名', max_length=255)
    # create_time = models.DateTimeField(verbose_name='创建时间', auto_created=True)
    create_time = models.DateTimeField(verbose_name='活动开始时间')
    status = models.IntegerField(verbose_name='状态', choices=((0, '准备中'), (1, '进行中'), (2, '结束')))
    description = models.CharField(verbose_name='备注', max_length=255, null=True, blank=True)


    class Meta:
        verbose_name = '活动'
        verbose_name_plural = verbose_name

    def __str__(self):
        return f"【{self.get_status_display()}】{self.name}"


class ActLog(models.Model):
    student = models.ForeignKey(Student, verbose_name='学生', on_delete=models.SET_NULL, null=True, blank=True)
    activity = models.ForeignKey(Activity, verbose_name='活动', on_delete=models.SET_NULL, null=True, blank=True)
    img_url = models.CharField(verbose_name='图片链接', null=True, blank=True, max_length=255)
    create_time = models.DateTimeField(verbose_name='创建时间', auto_created=True)

    class Meta:
        verbose_name = '参与活动记录'
        verbose_name_plural = verbose_name

    def __str__(self):
        return f"【{self.activity}】{self.student}({self.create_time})"


class NoLog(models.Model):
    act_name = models.CharField(max_length=100, verbose_name='活动名')
    ins_name = models.CharField(max_length=100, verbose_name='学院名')
    classname = models.CharField(max_length=100, verbose_name='班级')
    name = models.CharField(max_length=100, verbose_name='姓名')
    phone = models.CharField(max_length=100, verbose_name='手机')
    dorm = models.CharField(max_length=100, verbose_name='寝室')

    class Meta:
        managed = False
        db_table = "no_log"
        verbose_name = '未完成学生'
        verbose_name_plural = verbose_name
